<CFQUERY NAME="getorders" DATASOURCE="#dsn#">
select * 
from tblprofiles
order by LastName
</CFQUERY>

<cfif isdefined("form.productname")>
<CFQUERY NAME="getitem" DATASOURCE="#dsn#">
select *
from tblproducts
where ProductName like '%#ProductName#%' <cfif #category# neq ""> or Category = '#Category#'</cfif>
</CFQUERY>

</cfif>

<!---<cfif isdefined("session.ReceiptNum")>
<CFQUERY NAME="getorders" DATASOURCE="#dsn#">
select *
from tblorders
where ReceiptNum = #session.ReceiptNum#
</CFQUERY>

<CFQUERY NAME="getitems" DATASOURCE="#dsn#">
select *
from tbltransactions, tblproducts
where ReceiptNum = #session.ReceiptNum# and tbltransactions.ProdID = tblproducts.ProdID
</CFQUERY>

<CFQUERY NAME="getitemssum" DATASOURCE="#dsn#">
select sum(Price) as total
from tbltransactions
where ReceiptNum = #session.ReceiptNum#
</CFQUERY>

</cfif>

<cfif isdefined("form.amountpaid")>
<cfset mychange = #form.amountpaid# - #form.Amount#>
<cfif #form.amountpaid# lt #form.Amount#>
<cfset myblance = #mychange#>
<cfelse>
<cfset myblance = 0>

</cfif>
<cfset today = dateformat(now(), "mm/dd/yyyy")>
<cfset mytime = timeformat(now(), "hh:mm:ss tt")>


<CFQUERY DATASOURCE="#dsn#">
update tblorders
set Cash = #amount#,
Change = #mychange#,
TransType = 'POS',
LastFour = #session.pin#


where ReceiptNum = #session.ReceiptNum#
</CFQUERY>


<CFQUERY DATASOURCE="#dsn#">
INSERT INTO tblpayments (Amount, ReceiptNum, TransDate, ReportTime, ReportDate, PaymentType, PIN, Change, username, amountpaid, Balance)
VALUES (
#Amount#,
#session.ReceiptNum#,
<cfqueryparam cfsqltype="cf_sql_timestamp" value="#today#">,
'#mytime#',
'#today#',
'CASH',
#session.pin#,
#mychange#,
'#session.username#',
#amountpaid#,
<cfif #myblance# gte 1>#myblance#<cfelse>0</cfif>
 
)
</CFQUERY>


</cfif>--->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 14px;
	color: #FFFFFF;
}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #1b3b63;
}
.style1 {
	font-size: 18px;
	font-weight: bold;
}
.style5 {
	font-size: 20px;
	font-weight: bold;
}
.style7 {font-size: 36px}
-->
</style>

<script>
<!--

function DollarFormat(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();

if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+''+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + '.' + cents);
}
//-->
</script>
</head>

<body onLoad="document.form1.amount.focus()"><cfoutput><!---<cfif isdefined("form.ProductName")><table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="15%">&nbsp;</td>
    <td width="20%" height="35"><strong>UPC</strong></td>
    <td width="23%" height="35"><strong>Category</strong></td>
    <td width="42%" height="35"><strong>Name</strong></td>
  </tr>
  <cfloop query="getitem"><tr>
    <td><a href="../additem.cfm?prodid=#prodid#" target="_parent"><img src="../images/select.png" width="75" height="25" border="0" /></a></td>
    <td height="36"><span class="style4">#prodid#</span></td>
    <td height="36">#Category#</td>
    <td height="36">#ProductName#</td>
  </tr></cfloop>
</table>
<cfelse>---><cfif isdefined("url.message")><table width="96%" height="318" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="35" colspan="2" valign="middle"><span class="style5">ADD CASH TO DRAWER</span></td>
        </tr>
        <tr>
          <td colspan="2"><hr size="1" noshade="noshade" /></td>
        </tr>
       
        <tr>
          <td width="60%" colspan="2" valign="top" class="style1"><br />
            #url.message#<br />
          <br />          <label></label>          <label></label>          <label></label></td>
        </tr>
        
      </table>
<cfelse><cfform name="form1" method="post" action="form_cash_save.cfm">
      <table width="96%" height="318" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="35" colspan="2" valign="middle"><span class="style5">ADD CASH TO DRAWER</span></td>
        </tr>
        <tr>
          <td colspan="2"><hr size="1" noshade="noshade" /></td>
        </tr>
        <cfif not isdefined("form.amountpaid")></cfif>
        <tr>
          <td width="40%" valign="middle" class="style1"><br />
            Enter Cash Amount:<br />
          <br /></td>
          <td width="60%" height="55" align="left" valign="middle"><label>
            <span class="style7">$            </span>
            <cfinput type="text" name="amount" class="style5" size="10" onblur="this.value =
DollarFormat(this.value);">
          </label></td>
        </tr>
        <tr>
          <td height="55" class="style1">&nbsp;</td>
          <td align="right">&nbsp;</td>
        </tr>
        <tr>
          <td height="55" class="style1">&nbsp;</td>
          <td><label></label></td>
        </tr>
        <tr>
          <td height="36" class="style11">&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td height="67" colspan="2" align="left"><label>
            <cfinput type="image" name="Submit" value="Submit" src="../images/enter.png">
          </label></td>
        </tr>
      </table>
    </cfform></cfif><!---</cfif>---></cfoutput>
    </td>
    </tr>
</table>
</body>
</html>
